package com.tanguy.user.utlis.extend

import java.text.SimpleDateFormat
import java.util.*

/**
 * Created by dab on 2017/11/23 0023 09:40
 */
fun Long.toTimeString(pattern: String): String {
    val f = SimpleDateFormat(pattern, Locale.CHINA)
    return f.format(Date(this))
}

/**
 * 1->01
 * 10->10
 */
fun Long.toTimeComplement(): String = if (this < 10) "0" + this else this.toString()

fun Double.toReserveDecimal(digit: Int): String = String.format(Locale.CHINA, "%.${digit}f", this)